package testing;

public class TransferThread extends Thread{

	
	Bank a;
	
	int max;
	
	String id;
	
	
	public TransferThread(Bank a,int max, String id) {
		
		this.a = a;
		
		this.max = max;
		
		this.id = id;
		
		
	}
	

	public void corre(){
	
		int go = 0;
		
		while(go<max){
		
		//System.out.println("thread: "+id+" Conta 1: "+a.getAccount(1).getBalance());
		//System.out.println("thread: "+id+" Conta 2: "+a.getAccount(2).getBalance());
		//a.getAccount(1).balance = 2;
		a.transfer(1, 2, 100);
		a.transfer(2, 1, 100);
		a.transfer(1, 2, 100);
		a.transfer(2, 1, 100);
		a.transfer(1, 2, 100);
		a.transfer(2, 1, 100);
		a.transfer(1, 2, 100);
		a.transfer(2, 1, 100);
		a.transfer(1, 2, 100);
		a.transfer(2, 1, 100);
		a.transfer(1, 2, 100);
		a.transfer(2, 1, 100);
		//System.out.println("thread: "+id+" Conta 1: "+a.getAccount(1).getBalance());
		//System.out.println("thread: "+id+" Conta 2: "+a.getAccount(2).getBalance());
		
/*		a.transfer(2, 1, 100);
		a.transfer(1, 2, 20);
		a.transfer(2, 1, 1);
		a.transfer(1, 2, 10);
		a.transfer(2, 1, 30);
		a.transfer(1, 2, 60);
		a.transfer(2, 1, 150);
		a.transfer(1, 2, 160);
		a.transfer(2, 1, 60);
		a.transfer(1, 2, 75);
		a.transfer(1, 2, 82);
		a.transfer(2, 1, 63);
		a.transfer(1, 2, 90);
		a.transfer(1, 2, 100);
		a.transfer(2, 1, 100);*/
		
		go++;
		}
		
		
		
	
	}
	
	public void run() {
		
		corre();
		
	}

	

	
	
}
